﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.IO;
using System.Net;

namespace Microserve.TeleEye.Data
{
    public class HomePage
    {
        string data = string.Empty;
        public HomePage()
        {
            //data = SourceDownloader.GetSource("http://www.teleeye.com/Eng/index.html");
            //data = data.Replace("&nbsp;", string.Empty);
            //data = data.Replace("&", "&amp;");
            //data = data.Replace("<br>", string.Empty);
            //data = data.Replace("\r\n", string.Empty);                       
        }

        public XmlDocument GetPageMenu(string menuTitle)
        {
            int startIndex = data.IndexOf("/>" + menuTitle);
            int startWhatsNewDivIndex = data.IndexOf("<div", startIndex);
            int endWhatsNewDivIndex = data.IndexOf("</div>", startWhatsNewDivIndex);
            int whatsNewLength = endWhatsNewDivIndex + "</div>".Length - startWhatsNewDivIndex;

            string subMenuItems = data.Substring(startWhatsNewDivIndex, whatsNewLength).Replace(@"<div class=""submenu""> </a>",
                @"<div class=""submenu"">");                        
            
            XmlDocument whatsNewMenu = new XmlDocument();
            whatsNewMenu.LoadXml(subMenuItems);
        
            return whatsNewMenu;
        }

        public void GetFeaturedProducts()
        {

        }
    }
}
